package data;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import pl.edu.agh.mwo.importxls.ImportExcel;
import fileFinder.FileImporter;

public class Operator {

	private static AReport currentAReport;
	private static BReport currentBReport;
	private static TaskList taskList;
	
	public static void printDatabaseInfo() {
		ArrayList<Task> currentTaskList = taskList.getTaskList();
		int counter =0;
		for (Task task: currentTaskList) {
			System.out.println(counter++);
			System.out.println(task);
		}	
	}
	
	public static void printPersonInfo() {
		ArrayList<Person> currentPersonList = taskList.getPersonList();
		int counter =0;
		for (Person person: currentPersonList) {
			System.out.println(counter++);
			System.out.println(person);
		}
	}
	
	public static void sendAddressString (String filepath) {
		ImportExcel xclImporter = new ImportExcel();
		taskList = new TaskList();
		taskList.clearTaskList();
		FileImporter fi = new FileImporter();
		List<File> fileList = fi.scanForFiles(filepath);
		for (File file: fileList) {
			String fp = file.getAbsolutePath();
			try {
				xclImporter.readExcelFile(fp, taskList);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public static void chooseReportType (String type) {
		switch (type) {
		case "A":
			setARecord(ReportGenerator.generateAReport(taskList));
			break;
		case "B":
			setBRecord(ReportGenerator.generateBReport(taskList));
			break;
		default :
			break;
		}
	}
	
	public static AReport getCurrentAReport() {
		return currentAReport;
	}

	public static AReport getCurrentBReport() {
		return currentAReport;
	}
		
	private static void setARecord(AReport inputReport) {
		currentAReport = inputReport;
	}
	
	private static void setBRecord(BReport inputReport) {
		currentBReport = inputReport;
	}	
}
